package com.beta.auth.utils;

import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;

public class WXUtils {

    private WXUtils(){}

    public static String getNonceString(int length) {
        try {
            String base = "abcdefghijklmnopqrstuvwxyz0123456789";
            SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
            StringBuffer sb = new StringBuffer();
            for (int i = 0; i < length; i++) {
                int number = random.nextInt(base.length());
                sb.append(base.charAt(number));
            }
            return sb.toString();
        } catch (NoSuchAlgorithmException nsae) {
            return null;
        }
    }
}
